<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>主页</title>
		<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
		<link rel="stylesheet" type="text/css" href="css/index.css"/>
		<script src="js/bootstrap.min.js"></script>
		<script src="js/jquery-3.3.1.min.js"></script>
		<script src="js/jquery.cookie.js"></script>
	</head>
	<body>
		<div class="container" id="top">
			<div class="row">
				<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6" id="welcome">
					<div class="row">
						<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4"></div>
						<div class="col-xs-3 col-sm-3 col-md-3col-lg-3" id="user_hover"></div>
					</div>
				</div>
				<div class="col-xs-5 col-sm-5 col-md-5 col-lg-5" id="menu">
					<div class="row">
						<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2" id="order_father">
							<a href="myorder.html?page=1">我的订单</a>
						</div>
						<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2"  id="cart_father">
							<a href="mycar.html">&nbsp;我的购物车&nbsp;</a>
						</div>
						<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2" id="receive_address_father">
							<a href="myaddress.html" id="myaddress">我的收货地址</a>
						</div>
						<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2" id="shop_father">
							<p><img class="top_logo" src="images/index/shop.png"/>&nbsp;我的店铺<img class="down_arrow" src="images/index/down_arrow.png"/></p>
							<div class="child" id="shop_child"></div>
						</div>
						<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2" id="collection_father">
							<p id="toman">&nbsp;后台管理&nbsp;</p>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="container" id="search">
			<div class="row">
				<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3" id="a"></div>
				<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6" id="search_input">
					<div id="type"><button class="type_choise" id="searchgoods">商品</button><button class="type_unchoise" id="searchshop">店铺</button></div>
					<input type="text" id="search_what"/><button id="search_btn">搜索</button>
				</div>
			</div>
		</div>
		<div class="container" id="navigation">
			<div class="row">
				<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div>
				<div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
					<div class="row kpl">
						<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2" id="navigation_address">快捷入口&nbsp;&nbsp;<img src="images/index/down_arrow_white.png"/></div>
						<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1" id="navigation_index"><a href="index.html">首页</a></div>
						<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"><a href="updata_information.html">个人中心</a></div>
						<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"><a href="mycar.html">我的购物车</a></div>
						<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"><a href="myaddress.html">我的收货地址</a></div>
						<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"><a href="myorder.html?page=1">我的订单</a></div>
						<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"><a>我的店铺</a></div>
						<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1" id="tomanager"><a href="manager.html">后台管理</a></div>
						<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1" id="mymessage">我的消息<span id="messagenum"></span></div>
					</div>
				</div>
			</div>
		</div>
		<div class="container" id="address_carousel">
			<div class="row">
				<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div>
				<div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
					<div class="row">
						<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2" id="address">
							<div class="row address_li">
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
								<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><a href="goodslist.html?search=苹果&page=1">苹果</a></div>
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><img class="address_arrow" src="images/index/right_arrow.png"/></div>
							</div>
								<div class="row address_li">
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
								<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6" ><a href="goodslist.html?search=香蕉&page=1">香蕉</a></div>
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><img class="address_arrow" src="images/index/right_arrow.png"/></div>
							</div>
								<div class="row address_li">
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
									<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><a href="goodslist.html?search=西瓜&page=1">西瓜</a></div>
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><img class="address_arrow" src="images/index/right_arrow.png"/></div>
							</div>
								<div class="row address_li">
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
									<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><a href="goodslist.html?search=榴莲&page=1">榴莲</a></div>
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><img class="address_arrow" src="images/index/right_arrow.png"/></div>
							</div>
								<div class="row address_li">
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
									<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><a href="goodslist.html?search=桃子&page=1">桃子</a></div>
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><img class="address_arrow" src="images/index/right_arrow.png"/></div>
							</div>
								<div class="row address_li">
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
									<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><a href="goodslist.html?search=梨&page=1">梨</a></div>
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><img class="address_arrow" src="images/index/right_arrow.png"/></div>
							</div>
								<div class="row address_li">
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
								<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><a href="goodslist.html?search=香菇&page=1">香菇</a></div>
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><img class="address_arrow" src="images/index/right_arrow.png"/></div>
							</div>
								<div class="row address_li">
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
									<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><a href="goodslist.html?search=生菜&page=1">生菜</a></div>
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><img class="address_arrow" src="images/index/right_arrow.png"/></div>
							</div>
								<div class="row address_li">
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
									<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><a href="goodslist.html?search=黄瓜&page=1">黄瓜</a></div>
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><img class="address_arrow" src="images/index/right_arrow.png"/></div>
							</div>
								<div class="row address_li">
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
									<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><a href="goodslist.html?search=菠菜&page=1">菠菜</a></div>
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><img class="address_arrow" src="images/index/right_arrow.png"/></div>
							</div>
								<div class="row address_li">
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
								<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><a href="goodslist.html?search=豆角&page=1">豆角</a></div>
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><img class="address_arrow" src="images/index/right_arrow.png"/></div>
							</div>
								<div class="row address_li">
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
								<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><a href="goodslist.html?search=茄子&page=1">茄子</a></div>
								<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"><img class="address_arrow" src="images/index/right_arrow.png"/></div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="container" id="recommend_goods">
			<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div>
			<div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
				<div class="row">
					<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 recommend_goods_img"><img src="images/index/recommend_goods_01.jpg"/></div>
					<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 recommend_goods_img"><img src="images/index/recommend_goods_01.jpg"/></div>
					<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 recommend_goods_img"><img src="images/index/recommend_goods_01.jpg"/></div>
					<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 recommend_goods_img"><img src="images/index/recommend_goods_01.jpg"/></div>
				</div>
			</div>
		</div>
		<div class="container" id="bottom"><p>© 2012-2020 Benlai.com. All Rights Reserved. *****有限公司</p></div>

		<script type="text/javascript">

			// <!--判断是否已经登陆过-->
			function hasLogin() {

                var userId = $.cookie("userId");

                $.post("order/getMessage",{uid:userId},function (data) {
					data = JSON.parse(data);
                    $("#messagenum").html(data.length);
                });

                $("#mymessage").click(function () {
                    $.post("order/getMessage",{uid:userId},function (data) {
                        data = JSON.parse(data);
                        var message = '';
                        for (var i = 0; i < data.length; i++) {
							message += "您的订单" + data[i].onum + "已发货，请注意查收！";
							message += '\n';
                        }
                        alert(message);

                        $.post("order/delMessage",{uid:userId},function (data2) {
							location.href = "index.html";
                        })

                    });
                });


                //Cooklie中没有userId则未登录，否则已登陆，根据userId向后台查询用户信息。
                if (userId == null){
                    var wel = '<p id="welcome_p"><a href="login.html">前往登录</a>&nbsp;<a href="register.html">免费注册</a></p>';
                    $("#welcome").html(wel);
                }else {
					$.post("user/information",{userId:userId},function (data) {
					    var json = JSON.parse(data);
                        var wel = '';
					    if (json.username != null){
					        wel = '<div class="row"><div class="col-xs-4 col-sm-4 col-md-4 col-lg-4"></div><div class="col-xs-3 col-sm-3 col-md-3 col-lg-3" id="user_hover"><p>欢迎您,&nbsp;'+ json.username +'<img class="down_arrow" src="images/index/down_arrow.png"/></p></div></div>';
						}else {
                            wel = '<p>欢迎您,&nbsp;fvonline_'+ json.id +'<img class="down_arrow" src="images/index/down_arrow.png"/></p>';
						}
                        wel += '<div class="child" id="welcome_child"><img id="hs" src='+ "/FVOnline/user/getHS?userId=" + userId +' /><p id="integral">累计消费：<span>'+ json.integral +'</span></p><p id="updateInformation_exit"><a href="updata_information.html">修改信息&nbsp;&nbsp;</a><a id="exit">退出</a></p></div>';
                        $("#user_hover").html(wel);

                        $("#exit").click(function () {
                            $.removeCookie('userId',{ path: '/'});
                            location.href = "login.html";
                        });

                        $.get("shop/getShop",{userId:userId},function (data) {
							if (data.toLowerCase() == "null"){
								$("#shop_child").html("<a id='newshop'>十&nbsp;快速开店</a>");
								$("#newshop").click(function () {
								   location.href = "newshop.html";
                                });
							} else {

							    data = JSON.parse(data);

							    var shopname = data.shopname;
							    var state;

							    if (data.state == 0){
							        state = '审核中';
								}else if(data.state == 1){
                                    state = '营业中';
								}else if(data.state == 2){
                                    state = '封禁中';
                                }
								var ht = '<img id="shophs" src='+ "/FVOnline/shop/getHS?userId=" + userId +'><p class="inlinep">'+ shopname +'<span>'+ state +'</span></p>';
                                $("#shop_child").html(ht);

                                if (data.state == 1){
                                    $("#shop_child").click(function () {
										location.href = "shopdetails.html?shopid=" + data.id + "&page=1";
                                    });
								}

							}
                        });

                        /**
                         * 鼠标悬停显示个人信息
                         */
                        $("#user_hover").hover(function () {
                            $("#user_hover").addClass("divHover");
                            $("#welcome_child").removeClass("child");
                        },function () {
                            $("#user_hover").removeClass("divHover");
                            $("#welcome_child").addClass("child");
                        });


                        /**
                         * 鼠标悬停显示个人店铺信息
                         */
                        $("#shop_father").hover(function () {
                            $("#shop_father").addClass("divHover");
                            $("#shop_child").removeClass("child");
                        },function () {
                            $("#shop_father").removeClass("divHover");
                            $("#shop_child").addClass("child");
                        });

                    });
                }
            }
            hasLogin();

			$("#searchshop").click(function () {
                $("#searchshop").addClass("type_choise");
                $("#searchshop").removeClass("type_unchoise");

                $("#searchgoods").addClass("type_unchoise");
                $("#searchgoods").removeClass("type_choise");
            });

			$("#searchgoods").click(function () {

                $("#searchgoods").addClass("type_choise");
                $("#searchgoods").removeClass("type_unchoise");

                $("#searchshop").addClass("type_unchoise");
                $("#searchshop").removeClass("type_choise");
            });


			$("#search_btn").click(function () {
				var what = $("#search_what").val();

				if ($("#searchgoods").hasClass("type_choise")){
                    location.href = "goodslist.html?search=" + what + "&page=1";
				}

				if ($("#searchshop").hasClass("type_choise")) {
					location.href = "shoplist.html?search=" + what + "&page=1";
				}

            });

			$("#toman").click(function () {
				location.href = "manager.html";
            });


		</script>
	</body>
</html>
